import _init_paths
import os


def run_nohup(method, dataset, k_gnd, n_codebook, n_cluster, distance_function):
    log_fname = '%s_%d_%d_%d' % (dataset, k_gnd, n_codebook, n_cluster)
    os.system(
        'nohup python3 -u baseline/%s.py --dataset %s --topk %d --metric %s --num_codebook %d '
        '--Ks %d > ./log/baseline/%s.log 2>&1 &' % (
            method, dataset, k_gnd, distance_function, n_codebook, n_cluster, log_fname))


def run(method, dataset, k_gnd, n_codebook, n_cluster, distance_function):
    os.system(
        'python3 -u baseline/%s.py --dataset %s --topk %d --metric %s --num_codebook %d '
        '--Ks %d' % (
            method, dataset, k_gnd, distance_function, n_codebook, n_cluster))


if __name__ == '__main__':
    dataset_l = ['glove', 'deep']
    # dataset_l = ['siftsmall']
    k_gnd_l = [10]
    n_codebook_l = [4, 8, 16]
    n_cluster = 256
    # n_cluster = 16
    metric = 'euclid_norm'

    for ds in dataset_l:
        for k_gnd in k_gnd_l:
            for n_codebook in n_codebook_l:
                distance_type = "euclid_norm"
                if ds == 'glove' or ds == 'deep':
                    distance_type = 'angular'
                run('run_pq', ds, k_gnd, n_codebook, n_cluster, distance_type)
                run('run_opq', ds, k_gnd, n_codebook, n_cluster, distance_type)
                run('run_rq', ds, k_gnd, n_codebook, n_cluster, distance_type)
                # run_nohup('run_opq', ds, k_gnd, n_codebook, n_cluster)
